#八皇后问题主函数
Output = False
n = 0                                                                      #总的解的数量
nn = 0
times = 1
rows = int(input())
cols = rows
mygraph = [[0 for col in range(cols)] for row in range(rows)]  
mypath = []
patht = []
get = []
WIDTH = 900
HEIGHT = 900
import time
def on_mouse_down():
    global Output
    print("running")
#    global iterator
#    global nn
#    global control
#    print("on mouse down",patht[iterator])
#    print(get[0])
#    iterator += 1
#    nn += 1
    Output = True
    sovle(0,mygraph,mypath,patht,Output)
def sovle(deep, graph, path, patht,Output):
    '''解决八皇后问题的函数'''
#    Output = True

    if Output == True:
        for i in range(rows):
            if graph[deep][i] == 0:                                            #如果这个点没有灰化，则说明是有效点
                path.append((deep, i))
                if deep == rows - 1:                                              #如果到了第7层，即对应第八个皇后，则输出路径，跳出此路径
                    print(path)
                    global n 
                    n = n + 1
                    path.pop()
                    break

                else:
                    make_gray(graph, deep, i, 0, deep + 1)                     #灰化
                    sovle(deep + 1, graph, path,patht,Output)
                    make_gray(graph, deep, i, deep + 1, 0)                     #解灰化
        
                path.pop()
#    print("patht:",patht)
#    return patht

def make_gray(graph, x, y, oldvalue, newvalue):
    '''灰化函数,让点(x,y)所在行列，和斜线上的点为不可用，或者解除不可用状态'''
    for i in range(cols):
        if graph[x][i] == oldvalue:                                        #竖直方向设置为不可用
            graph[x][i] = newvalue 

        if graph[i][y] == oldvalue:
            graph[i][y] = newvalue                                         #横向设置为不可用

        slash(graph, x - 1, y - 1, -1, -1, oldvalue, newvalue)                 #左斜上方
        slash(graph, x + 1, y - 1, 1, -1, oldvalue, newvalue)                  #右斜上方
        slash(graph, x - 1, y + 1, -1, -1, oldvalue, newvalue)                 #左斜下方
        slash(graph, x + 1, y + 1, 1, 1, oldvalue, newvalue)                   #右斜下方


def slash(graph, x, y, x_increment, y_increment, oldvalue, newvalue):
    '''斜线方向上,graph为图数组，x为横坐标，y为纵坐标，x_increment为x方向增量，
        y_increment为y方向增量，oldvalue为老的值，newvalue为新设的值'''
    xx = x 
    yy = y
    while -1 < xx < rows and -1 < yy < cols:
        if graph[xx][yy] == oldvalue:
            graph[xx][yy] = newvalue

        xx += x_increment
        yy += y_increment

#    times += 1